package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectStore;
import com.ruoyi.system.service.IProjectStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 众筹参与表Controller
 * 
 * @author ruoyi
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/system/projectstore")
public class ProjectStoreController extends BaseController
{
    @Autowired
    private IProjectStoreService projectStoreService;

    /**
     * 查询众筹参与表列表
     */
    @PreAuthorize("@ss.hasPermi('system:store:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectStore projectStore)
    {
        startPage();
        List<ProjectStore> list = projectStoreService.selectProjectStoreList(projectStore);
        return getDataTable(list);
    }

    /**
     * 导出众筹参与表列表
     */
    @PreAuthorize("@ss.hasPermi('system:store:export')")
    @Log(title = "众筹参与表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectStore projectStore)
    {
        List<ProjectStore> list = projectStoreService.selectProjectStoreList(projectStore);
        ExcelUtil<ProjectStore> util = new ExcelUtil<ProjectStore>(ProjectStore.class);
        util.exportExcel(response, list, "众筹参与表数据");
    }

    /**
     * 获取众筹参与表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:store:query')")
    @GetMapping(value = "/{projectUserId}")
    public AjaxResult getInfo(@PathVariable("projectUserId") Long projectUserId)
    {
        return success(projectStoreService.selectProjectStoreByProjectUserId(projectUserId));
    }

    /**
     * 新增众筹参与表
     */
    @PreAuthorize("@ss.hasPermi('system:store:add')")
    @Log(title = "众筹参与表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectStore projectStore)
    {
        return toAjax(projectStoreService.insertProjectStore(projectStore));
    }

    /**
     * 修改众筹参与表
     */
    @PreAuthorize("@ss.hasPermi('system:store:edit')")
    @Log(title = "众筹参与表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectStore projectStore)
    {
        return toAjax(projectStoreService.updateProjectStore(projectStore));
    }

    /**
     * 删除众筹参与表
     */
    @PreAuthorize("@ss.hasPermi('system:store:remove')")
    @Log(title = "众筹参与表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectUserIds}")
    public AjaxResult remove(@PathVariable Long[] projectUserIds)
    {
        return toAjax(projectStoreService.deleteProjectStoreByProjectUserIds(projectUserIds));
    }
}
